package crm.implementor;


import crm.daoInterfaces.InfoSourceDao;
import crm.dbhandelling.Crude;
import crm.dto.InfoSource;


public class InfoSourceImp extends Crude implements InfoSourceDao
{

	private String className= new InfoSource().getClass().getName();
	@Override
	public void add(InfoSource info) throws Exception 
	{
		super.insert(info);
		
	}

	@Override
	public void update(InfoSource info) {
		super.update(className, "infoSourceName",info.getInfoSourceName(), "infoSourceCode", info.getAutoInfoSourceCode()+"");
		super.update(className, "status",info.getStatus()+"", "infoSourceCode", info.getAutoInfoSourceCode()+"");
		
	}

	@Override
	public void delete(InfoSource info) 
	{
		super.delete(className,"infoSourceCode", info.getAutoInfoSourceCode()+"" );
		
	}

	

	@Override
	public InfoSource[] retrieveAll() throws Exception
	{
		Object[] att=super.retreiveAll(className);
		InfoSource[] s=new InfoSource[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(InfoSource) att[i];
		return s;
		
		
	}

	@Override
	public InfoSource retrieve(String conditionField,String conditionValue) throws Exception 
	{
		InfoSource i=(InfoSource) super.retreive(className, conditionField, conditionValue);
		return i;
	}

	@Override
	public InfoSource[] retrieveArray(String conditionField,
			String conditionValue) throws Exception 
	{
		Object[] att=super.retreiveArrayOnCondition(className, conditionField, conditionValue);
		InfoSource[] s=new InfoSource[att.length];
		for(int i=0;i<s.length;i++)
				s[i]=(InfoSource) att[i];
		return s;
		
	}

	public int getAutoGenratedKey()
	  {
		 int key=super.getAutoGenratedKey(className,"autoinfoSourceCode") ;
		 return key;
	  }

}
